<?php
/**
 * Created by PhpStorm.
 * User: priestll
 * Date: 20-7-14
 * Time: 下午4:37
 */

namespace App\HttpController\Common;


use App\Biz\UserBiz;
use EasySwoole\WeChat\Bean\OfficialAccount\JsAuthRequest;
use priestll\easyswoole\http\Base;
use priestll\easyswoole\wechat\WeChatManager;


class Wechat extends Base
{
    /**
     * @Di(key="USER_BIZ")
     */
    protected $userbiz;

    /**
     * @Api(name="mobile",group="/common/login",description="手机登陆",path="/common/login/mobile")
     * @Method(allow={GET})
     * @ResponseParam(name="code",description="状态码")
     * @ResponseParam(name="result",description="api请求结果")
     * @ResponseParam(name="msg",description="api提示信息")
     * @ApiSuccess({"code":200,"result":[],"msg":"SUCCESS"})
     * @ApiFail({"code":400,"result":[],"msg":"FAIL"})
     * @Param(name="url",alias="域名不能为空",required="")
     */
    public function getJssdk()
    {
        $param = $this->request()->getRequestParam();
        $url=$param["url"];
        foreach ($param as $key=>$val)
        {
            if($key!="url")
            {
                $url.="&".$key."=".$val;
            }
        }
        $userBiz=new UserBiz();
        $res= $userBiz->jssdk($url);
        if ($res['status']) {
            $res=json_decode(json_encode($res),true);
            $res["url"]=$param["url"];
            $res["URL"]=$url;
            return $this->success($res["data"]);
        } else {
            return $this->fail($res['data']);
        }
    }

}